import React from 'react'
import { Link } from 'react-router-dom'

import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import { actions as UserAction } from '../../reducers/user'

import NoPermission from 'components/no-permission'

import List from './components/list'

class Grab extends React.Component {

    render() {
        const {userInfo: {is_execute}, conditions} = this.props
        
        return (
            <React.Fragment>
                {
                    is_execute ? 
                    <React.Fragment>
                        <div className="row">
                            <div className='hr'/>
                            <List conditions={conditions}/>
                        </div>
                        
                        <div className="p-btns">
                            <Link to='/new-project' className="release">发布新项目</Link>
                            <Link to="/contacts" className="contact">联系</Link>
                        </div>
                    </React.Fragment>
                     : <NoPermission text='抢单'/>
                }
            </React.Fragment>
        )    
    }
}

function mapStateToProps(state) {
    return {
        userInfo: state.user.userInfo
    }
}
  
function mapDispatchToProps(dispatch) {
    return  {
    }
}
  
export default connect(
    mapStateToProps,
    mapDispatchToProps
)(Grab)